<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<c:forEach items="${orders}" var="order">
	<div id="o${order.id}">
		<div class="weui_cells_title" style="background: #efefef; color: #000; font-size: 16px; margin-top: 15px;">
			<fmt:formatDate value="${ order.createdAt }" type="both" />
		</div>
		<c:set var="sum" value="0"></c:set>
		<c:set var="canCancel" value="0"></c:set>
		<c:forEach items="${order.storageOrder}" var="storageOrder">
			<div id="s${storageOrder.id}">
				<div class="weui_cells_title">
					<span>${storageOrder.storage.name}</span>
					<p style="float: right; color: #568aed;">${orderState[storageOrder.state]}</p>
				</div>
				<c:forEach items="${storageOrder.goodsOrder}" var="goodsOrder">
					<c:set var="sum" value="${sum+goodsOrder.num}"></c:set>
					<c:set var="canCancel" value="${canCancel+(goodsOrder.state!=21?1:0)}"></c:set>
					<div id="g${goodsOrder.id}">
						<div class="weui_cells weui_cells_access">
							<a class="weui_cell" href="javascript:;" style="border-bottom: #ddd 1px dashed; padding: 5px;">
								<div class="weui_cell_hd">
									<img src="${goodsOrder.image }" alt="" onclick="gotoHtml('/order/detail.html?orderId=${order.id}')"
										style="width: 60px; height: 60px; margin-right: 5px; display: block;">
								</div>
								<div class="weui_cell_bd weui_cell_primary">
									<p onclick="gotoHtml('/order/detail.html?orderId=${order.id}')">${goodsOrder.name}</p>
									<h4 onclick="gotoHtml('/order/detail.html?orderId=${order.id}')">
										<c:if test="${goodsOrder.points>=0}">
										￥
										<fmt:formatNumber value="${goodsOrder.price/100}" pattern="#,###.##" />
										</c:if>
										<c:if test="${goodsOrder.points<0}">
										积分${-goodsOrder.points}
										</c:if>
									</h4>
									<p>
										X${goodsOrder.num}
										<c:if
											test="${(state==0 || state==40)&&goodsOrder.commentState!=80&&(goodsOrder.state==40||goodsOrder.state==41||goodsOrder.state==60||goodsOrder.state==70)}">
											<input style="font-family: '黑体'; float: right;" type="button" class="weui_btn weui_btn_mini weui_btn_primary" value="去评价"
												onclick="doComment('${goodsOrder.id}')"></input>
										</c:if>
									</p>

								</div>
							</a>
						</div>
					</div>
				</c:forEach>
				<c:if test="${(state==0 || state==31)&&storageOrder.state==31}">
					<div id="${storageOrder.id}" class="button_sp_area" style="border-bottom: 1px dashed #ddd; text-align: right; padding: 5px;">
						<a href="javascript:brforeReceipt('${storageOrder.id}');" class="weui_btn weui_btn_mini weui_btn_primary">确认收货</a>
					</div>
				</c:if>
			</div>
		</c:forEach>
		<div style="height: 110px;">
			<div class="tjleft">
				<p>共${sum}件</p>
			</div>
			<div class="tjmid">
				<p>商品金额：</p>
				<p>优惠金额：</p>
				<p>运费：</p>
				<p>总计 ：</p>
			</div>
			<div class="tjright">
				<p>
					￥
					<fmt:formatNumber value="${order.goodsAmount/100}" pattern="#,###.##" />
				</p>
				<p>
					-￥
					<fmt:formatNumber value="${order.discountAmount/100}" pattern="#,###.##" />
				</p>
				<p>
					￥
					<fmt:formatNumber value="${order.freightAmount/100}" pattern="#,###.##" />
				</p>
				<p>
					￥
					<fmt:formatNumber value="${order.resultAmount/100}" pattern="#,###.##" />
				</p>
			</div>
		</div>
		<div class="button_sp_area" style="border-top: 1px dashed #ddd; text-align: right; padding-right: 5px; height: 30px;">
			<c:if test="${(state==0 || state==10)&&(order.state==10||order.state==20)}">
				<a href="javascript:payOrder('${order.code}');" class="weui_btn weui_btn_mini weui_btn_primary">&nbsp;去支付&nbsp;</a>
				<a href="javascript:cancelOrder('${order.id}');" class="weui_btn weui_btn_mini weui_btn_primary">取消订单</a>
			</c:if>
			<c:if test="${(state==0 || state==21)&&order.state==21&&canCancel==0}">
				<a href="javascript:cancelPayOrder('${order.id}');" class="weui_btn weui_btn_mini weui_btn_primary">取消订单</a>
			</c:if>
		</div>
	</div>
</c:forEach>



<c:if test="${over==true}">
	<input id="over" value="true" type="hidden" />
</c:if>
